//
//  SJAddWHCell.m
//  WSL
//
//  Created by CJ on 2017/10/16.
//  Copyright © 2017年 sanjuetech. All rights reserved.
//

#import "SJAddWHCell.h"
#import "SJAddItem.h"

@interface SJAddWHCell ()

@property (strong, nonatomic) UILabel *numbleLabel;
@property (strong, nonatomic) UIImageView *stateImageView;

@end

@implementation SJAddWHCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView addSubview:self.stateImageView];
    self.stateImageView.sd_layout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 0, 0));
    
    [self.contentView addSubview:self.numbleLabel];
    self.numbleLabel.sd_layout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 0, 0));
    
}


- (void)setItem:(SJAddItem *)item {
    
    _item = item;
    self.numbleLabel.text = item.numble;
    
    if ([item.state isEqualToString:@"0"]) {
        
        self.stateImageView.image = [UIImage imageNamed:@"upload_size_bg_nor"];
        _numbleLabel.textColor = SJColorHexString(@"#ffffff4d");
        
    } else if ([item.state isEqualToString:@"1"]) {
        
        self.stateImageView.image = [UIImage imageNamed:@"upload_size_bg_nor"];
        _numbleLabel.textColor = SJColorHexString(@"#ffffff");
        
    } else if ([item.state isEqualToString:@"2"]) {
        
        self.stateImageView.image = [UIImage imageNamed:@"upload_size_bg_sel"];
        _numbleLabel.textColor = SJColorHexString(@"#ffffff");
    }
    
}

#pragma mark - getter
- (UIImageView *)stateImageView{
    
    if (!_stateImageView) {
        
        _stateImageView = [UIImageView new];
        _stateImageView.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    return _stateImageView;
}

- (UILabel *)numbleLabel{
    
    if (!_numbleLabel) {
        
        _numbleLabel = [UILabel new];
        _numbleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(13)];
        _numbleLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    return _numbleLabel;
}
@end
